package com.dragons.spring5.annotation.service;

import com.dragons.spring5.annotation.dao.UserDao1;
import com.dragons.spring5.dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//在注解里面 value 属性值可以省略不写，默认值是类名称，首字母小写
//UserService -- userService
//@Component(value = "userService1") //<bean id="userService" class=".."/>
@Service
public class UserService1 {

//    @Autowired //定义 dao 类型属性 不需要添加 set 方法 添加注入属性注解
//    private UserDao1 userDao;

//    @Autowired // 根据类型注入
//    @Qualifier(value = "userDaoImpl1") // 根据名称注入
//    private UserDao1 userDao; // UserDao1有多个实现类

    //@Resource //根据类型进行注入
    @Resource(name = "userDaoImpl1") //根据名称进行注入
    private UserDao1 userDao;


    @Value(value = "abc")
    private String name;

    public void add() {
        System.out.println("service add.......");
        userDao.add();
    }
    public void normal(){
        System.out.println(name);
    }

}

